/*
 * =====================================================================================
 *
 *       Filename:  fork2.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  04/10/2012 02:45:09 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Zhiyi Wu (Z.W), zhiyiw@uoregon.edu
 *        Company:  University of Oregon
 *
 * =====================================================================================
 */
#include <unistd.h>

#include	"stdio.h"
#include <sys/types.h>



main ()

{

	pid_t pid;

	pid=fork();



	if (pid < 0)

		printf("error in fork!");

	else if (pid == 0)
{
		printf("I am the child process, my process id is %d.\n",getpid());

	execl("/bin/ls","ls","-la",NULL);
}
	else

		printf("I am the parent process, my process id is %d,my child is %d.\n",getpid(),pid);

}
